// Functions associated with the ModelAsset class
//-----------------

//-----------------
// Includes libraries and other files
#include "ModelAsset.h"
//-----------------

//-----------------
//// CONSTRUCTOR - ModelAsset
ModelAsset::ModelAsset()
	: mesh_( nullptr), dimensions_( 5.0f, 5.0f, 5.0f), file_name_( ""), asset_name_( ""), asset_type_( 0)
{}

//// CONSTRUCTOR - ModelAsset
ModelAsset::ModelAsset( const ModelAsset& m)
	: mesh_( m.get_mesh()), dimensions_( m.get_dimension_x(), m.get_dimension_y(), m.get_dimension_z()),
	  file_name_( m.get_file_name()), asset_name_( m.get_asset_name()), asset_type_( m.get_asset_type())
{}

//// DESTRUCTOR - ~ModelAsset
ModelAsset::~ModelAsset() {}
//-----------------

//-----------------
//// FUNCTION - get_mesh
// return the asset's mesh
Mesh* ModelAsset::get_mesh() const {
	// Pre-conditions :- none
	assert( true);

	return mesh_;
}

//// FUNCTION - get_file_name
// return the asset's file name (i.e. where the asset is loaded from)
std::string ModelAsset::get_file_name() const {
	// Pre-conditions :- none
	assert( true);

	return file_name_;
}

//// FUNCTION - get_asset_name
// return the asset's name (i.e. the one provided by the user)
std::string ModelAsset::get_asset_name() const {
	// Pre-conditions :- none
	assert( true);

	return asset_name_;
}

//// FUNCTION - get_asset_type
// return the asset's type (i.e. Floor, Door, Wall etc.)
int ModelAsset::get_asset_type() const {
	// Pre-conditions :- none
	assert( true);

	return asset_type_;
}

//// FUNCTION - get_dimension_x
// return the x dimension of the object
float ModelAsset::get_dimension_x() const {
	// Pre-conditions :- none
	assert( true);

	return dimensions_.x;
}

//// FUNCTION - get_dimension_y
// return the y dimension of the object
float ModelAsset::get_dimension_y() const {
	// Pre-conditions :- none
	assert( true);

	return dimensions_.y;
}

//// FUNCTION - get_dimension_z
// return the z dimension of the object
float ModelAsset::get_dimension_z() const {
	// Pre-conditions :- none
	assert( true);

	return dimensions_.z;
}

//// FUNCTION - set_mesh
// set the asset's mesh pointer to a mesh
void ModelAsset::set_mesh( Mesh* m) {
	// Pre-conditions :- the pointer must be valid
	assert( m != nullptr);

	mesh_ = m;
	file_name_ = m->get_file_name();
}

//// FUNCTION - set_asset_name
// set the asset's name (that will be displayed on the sidebar)
void ModelAsset::set_asset_name( const std::string& a) {
	// Pre-conditions :- none
	assert( true);

	asset_name_ = a;
}

//// FUNCTION - set_asset_type
// set the type of asset (e.g. Floor, Door, Wall etc.)
void ModelAsset::set_asset_type( const int& t) {
	// Pre-conditions :- value must be positive
	assert( t >= 0);

	asset_type_ = t;
}

//// FUNCTION - set_dimensions
// set the dimensions of the model
void ModelAsset::set_dimensions( const float& x, const float& y, const float& z) {
	// Pre-conditions :- the dimensions must be positive numbers
	assert( x >= 0 && y >= 0 && z >= 0);

	dimensions_.x = x;
	dimensions_.y = y;
	dimensions_.z = z;
}

//// FUNCTION - fill_in_the_blanks
// to be used on new assets before they can be given proper details by the user
void ModelAsset::fill_in_the_blanks( const int& m) {
	// Pre-conditions :- the asset name must be absent
	assert( asset_name_ == "");

	asset_name_ = file_name_;
	asset_type_ = m;
}

//// OVERLOADED OPERATOR - ==
bool ModelAsset::operator ==( const ModelAsset& a) const {
	// Pre-conditions :- none
	assert( true);

	// test if the assets are loading the same file
	if( get_file_name() == a.get_file_name())
		return true;
	else
		return false;
}

//// OVERLOADED OPERATOR - <
bool ModelAsset::operator <( const ModelAsset& a) const {
	// Pre-conditions :- none
	assert( true);

	// order the assets alphabetically so the nameless assets are last
	if( get_file_name() < a.get_file_name())
		return true;
	else
		return false;
}

//// OVERLOADED OPERATOR - >
bool ModelAsset::operator >( const ModelAsset& a) const {
	// Pre-conditions :- none
	assert( true);

	// > is the opposite of <
	return !( (*this) < a);
}